﻿#region Header
// ------------------------ Licence / Copyright ------------------------
// 
// Simple Service Administration Tool for WinNT based systems.
// Copyright © 2010 - Silvan Gehrig
// 
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
// 
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
// Lesser General Public License for more details.
// 
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
// 
// Author:
//  Silvan Gehrig
//
// ---------------------------------------------------------------------
#endregion

#region Usings

using SSATool.Common.Util;
using SSATool.DL.Common;

#endregion

namespace SSATool.BL.DM
{
    /// <summary>
    /// Represents the domain data layer entry point.
    /// </summary>
    public class DomainContext
    {
        #region Declarations
        //--------------------------------------------------------------------
        // Declarations
        //--------------------------------------------------------------------

        private readonly IClientDataProvider _dataProvider;

        private readonly Connection _connection;
        private readonly ServiceCollection _services;
        
        #endregion

        #region Properties
        //--------------------------------------------------------------------
        // Properties
        //--------------------------------------------------------------------

        /// <summary>
        /// Gets the underlying data connection instance.
        /// </summary>
        public Connection Connection
        {
            get { return _connection; }
        }

        /// <summary>
        /// Gets a list of windows services.
        /// </summary>
        public ServiceCollection Services
        {
            get { return _services; }
        }

        /// <summary>
        /// Gets the internal data provider instance.
        /// </summary>
        internal IClientDataProvider DataProvider
        {
            get { return _dataProvider; }
        }

        #endregion

        #region Constructors / Destructor
        //--------------------------------------------------------------------
        // Constructors / Destructor
        //--------------------------------------------------------------------

        /// <summary>
        /// Initializes a new instance of the <see cref="DomainContext"/> class.
        /// </summary>
        public DomainContext(IClientDataProvider dataProvider)
        {
            PreCondition.AssertNotNull(dataProvider, "dataProvider");

            _dataProvider = dataProvider;
            _connection = new Connection(this);
            _services = new ServiceCollection(this);
        }

        #endregion

        #region Methods
        //--------------------------------------------------------------------
        // Methods
        //--------------------------------------------------------------------

        internal void InitDataContainers()
        {
            _services.Reset();
        }

        #endregion

        #region Events
        //--------------------------------------------------------------------
        // Events
        //--------------------------------------------------------------------

        #endregion
    }
}
